package com.twentytwok.hospitalsystem22K.controller;


import com.twentytwok.hospitalsystem22K.common.R;
import com.twentytwok.hospitalsystem22K.pojo.User;
import com.twentytwok.hospitalsystem22K.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;


/*
/
 */
@RestController
@RequestMapping("/api/user")
@CrossOrigin("*")
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * 用户登录
     *
     * @author Yuanao
     * @date 2021年11月13日15:04:50
     *
     * @param id 用户的id
     * @param password 用户的密码 md5加密后的
     * @return Json
     */
    @RequestMapping("/login")
    public R login(@RequestParam  Integer id ,@RequestParam String password) {
        return userService.login(id,password);
    }

    @RequestMapping("/list")
    public List<User> findUsers() {

        return userService.findUsers();
    }

    @RequestMapping("/pageData")
    public R getPageData(@RequestParam Map<String, Object> params) {

        return userService.getPageData(params);
    }

    @RequestMapping("/addUser")
    public R addUser(User user) {
        return userService.addUser(user);
    }

    @RequestMapping("/delete")
    public R deleteById(Integer id) {
        return userService.deleteById(id);
    }

    @RequestMapping("/update")
    public R updateById(User user) {
        return userService.updateById(user);
    }

    @RequestMapping("selectUserById")
    public R selectUserById(Integer id) {
        return userService.selectUserById(id);
    }
}
